package tests
{
	import com.salesforce.objects.*;
	import com.salesforce.results.QueryResult;
	import com.salesforce.results.SearchResult;
	
	import flexunit.framework.*;
	
	public class QueryTest extends TestCase
	{
	    public function testSearch():void  
	    {   
	    	TestModel.getGlobal().apex.search("find {new account* }", new AsyncTestResponder(searchHandler, this, 4000));
	    }
	    
	    private function searchHandler(result:SearchResult):void 
	    {
	    	assertNotNull(result);
	    	assertNotNull(result.searchRecords);
	    	assertTrue(result.searchRecords.length > 1);	
	    }

		public function testQuery():void 
		{
			TestModel.getGlobal().apex.query("select id from account limit 2", new AsyncTestResponder(queryHandler, this, 4000));
		}		
		
	    private function queryHandler(result:QueryResult):void
	    {
	  		assertNotNull(result);
	  		assertNotNull(result.records);
	  		assertTrue(result.records.length == 2);
	    }
	}
}